/*
 * Created: Author: Ivan Lampert / Date: Jan 25, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-03-17 01:11:42 +0000 (Tue, 17 Mar 2015) $
 */
package com.cpm.aggregate;

import com.cpm.wrapper.SolidNumbers;
import com.cpm.wrapper.SolidStrings;

public final class Color implements StyleAttribute {
    private static final long serialVersionUID = -7328307347392238113L;

    private final String color;
    private final String rgb;

    public Color(String color) {
        SolidStrings.notEmpty(color);
        this.color = color;
        this.rgb = null;
    }
    
    public Color(int r, int g, int b){
        SolidNumbers.maximumAllowed(255, r, g, b);
        SolidNumbers.minimumAllowable(0, r, g, b);
        this.rgb = "rgb(" + r +", " + g + ", " + b + ")";
        this.color = null;
    }
    
    @Override
    public final String getValue() { 
        return "color:" + (rgb != null ? rgb : color)+ ";";
    }
}
